#ifndef __BASIC_GEOMETRY_H__
#define __BASIC_GEOMETRY_H__

#pragma once

#include "RenderMesh.h"
#include "SceneNode.h"

namespace Nezha
{

	/** basic animatable geometry. */
	class NEZHA_ENGINE_ENTRY BasicGeometry : public SceneNode
	{
	public:
			virtual RenderObjectType getROType() const
			{
				return ROT_ANIMATED;
			}

			virtual int getSceneObjectType() const
			{
				return SOT_GEOMETRY;
			}

			virtual const _string& getROName() const
			{
				return getName();
			}

			virtual SceneNode* getSpatial();

			virtual void update(float dt);

			virtual void addToRenderQueue();

			// TODO animation states

			// TODO bind creation to manager.

			/**
			@remarks
				set material to all sub meshs.
			*/
			void setMaterial(u32 i, const MaterialPtr& mat);

			u32 getNumSubMeshs() const
			{
				return mMeshSubsets.size();
			}

			const AABB& getLocalAABB() const
			{
				return mLocalAABB;
			}

			RenderMeshPtr getSubMesh(u32 i);

			BasicGeometry(const _string& name, RenderMesh* mesh);
			BasicGeometry(const _string& name, const PArray<RenderMesh*>& subMeshs);

	protected:
			virtual void updateGeometryBound(AABB& aabb) const;

	protected:
		typedef PArray<RenderMeshPtr> MeshSubsets;
		MeshSubsets mMeshSubsets;

		AABB mLocalAABB;
	};

}//end namespace Nezha

#endif //end __BASIC_GEOMETRY_H__